deterministic finite state machine